#!/bin/bash -
#=======================================================================
#
#          FILE: netconsole_monitor.sh
#         USAGE: ./netconsole_monitor.sh <ip>
#   DESCRIPTION: Fetch console output of devel machine (from monitor)
#  REQUIREMENTS: TBD
#          BUGS: N/A
#         NOTES: N/A
#        AUTHOR: Ali Ayoub
#         EMAIL: ali@mellanox.com
#       COMPANY: N/A
#       CREATED: 09.17.2010-15:26:23
#      REVISION: 1.0
#=======================================================================

USAGE="Usage: $0 <ip-to-monitor>"
EXAMPLE="Example: $0 10.20.1.21"

if [ $# != 1 ]; then
  echo $USAGE
  echo $EXAMPLE
  exit 1
fi


ip=$1
cmd="tail -f /var/log/messages | grep ' $ip '"

if ! ( ps -lefc | grep syslog | grep syslogd | grep '\-m 0 \-r \-x' -q);  then
	echo "-E- please set SYSLOGD_OPTIONS='-m 0 -r -x'"
        echo "    in /etc/sysconfig/syslog and restart syslog service"
	exit 1
fi
dmesg -n 8
nohup xterm -bg black -fg white -title "netconosle $ip" -hold -e "$cmd" &

